
#include "phys_body.h"

PhysicsBody::PhysicsBody(b2World* gameWorld)
{
    this->gameWorld = gameWorld;

    //Body Def
    bodyDef.type = b2_dynamicBody;
    bodyDef.position.Set(0,0);   // the body's origin position.
    bodyDef.angle = b2_pi;      // the body's angle in radians.
    bodyDef.linearDamping = 0.02f;
    bodyDef.angularDamping = 0.4f;
    bodyDef.gravityScale = 0.0f; // Set the gravity scale to zero so this body will float
    bodyDef.allowSleep = false;
    //bodyDef.awake = true;
    //bodyDef.fixedRotation = false;
    //bodyDef.userData = this;
    //bodyDef.active = true;

    //shape Def
    b2PolygonShape dynamicBox;
    dynamicBox.SetAsBox(1, 1);

    //fixture def 
    b2FixtureDef fixtureDef;
    fixtureDef.shape = &dynamicBox;
    fixtureDef.density = 5.0f;
    fixtureDef.friction = 0.0f;

    //Fire it up
    this->dynamicBody = this->gameWorld->CreateBody(&bodyDef);
    this->dynamicBody->CreateFixture(&fixtureDef);

    //myWorld->DestroyBody(dynamicBody);
    //dynamicBody = NULL;

}
